#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <utility>
using namespace std;

const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

#define mm(a, n) memset(a, n, sizeof a)
#define mk(a, b) make_pair(a, b)

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<int, LL> PIL;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

const int N = 500 + 10;

int n, m, s, d;
PII g[N][N];
int dist[N], cost[N];
bool st[N];
vector<int> pre[N];
vector<int> path, res_path;
int min_cost = INF;

void Dijkstra() {
    mm(dist, INF);
    mm(cost, INF);
    mm(st, false);

    dist[s] = 0;
    cost[s] = 0;

    for (int i = 0; i < n; i ++ ) {
        int t = -1;
        for (int j = 0; j < n; j ++ ) {
            if (!st[j] && (t == -1 || dist[j] < dist[t]))
                t = j;
        }
        st[t] = true;
        for (int j = 0; j < n; j ++) {
            if (dist[t] + g[t][j].first < dist[j]) {
                pre[j].clear();
                pre[j].push_back(t);
                dist[j] = dist[t] + g[t][j].first;
                cost[j] = cost[t] + g[t][j].second;
            } else if (dist[t] + g[t][j].first == dist[j]) {
                if (cost[t] + g[t][j].second < cost[j]) {
                    pre[j].clear();
                    pre[j].push_back(t);
                    cost[j] = cost[t] + g[t][j].second;
                } else if (cost[t] + g[t][j].second == cost[j]) {
                    pre[j].push_back(t);
                }
            }
        }
    }

}

void DFS(int u) {
    path.push_back(u);
    
    if (u == s) {
        res_path = path;
        reverse(res_path.begin(), res_path.end());
        path.pop_back();
        return ;
    }

    for (int i = 0; i < pre[u].size(); i ++ ) {
        DFS(pre[u][i]);
    }

    path.pop_back();
    return ;

} 

inline void solution() {
    mm(g, INF);
    cin >> n >> m >> s >> d;
    for (int i = 0; i < m; i ++ ) {
        int a, b, w, c;
        cin >> a >> b >> w >> c;
        g[a][b] = g[b][a] = mk(w, c);
    }
    Dijkstra();
    DFS(d);

    cout << res_path[0];
    for (int i = 1; i < res_path.size(); i ++ ) {
        cout << " " << res_path[i];
    }
    cout << " " << dist[d] << " " << cost[d] << endl;
    
    
    return ;
}

int main() {
    freopen("input.txt", "r", stdin);
    quickread();
    solution();
    return 0;
}